
<template>
  <div>
    <el-button type="primary" @click="executeEvent">{{
      element.componentProps.name
    }}</el-button>
  </div>
</template>
 
<script lang="ts">
import { defineComponent, inject, toRefs } from "vue";
import type { LowCodeImp, ComponentImp } from "@/components/low-code/core/type";

export default defineComponent({
  name: "buttonWidget",
  props: ["element"],
  setup(props) {
    const getLowCodeInstance = inject("getLowCodeInstance") as Function;
    const lowCode = getLowCodeInstance() as LowCodeImp;
    const { element } = toRefs(props);
    const executeEvent = () => {
      element.value.componentProps.onClickEvents.map(async(code: any) => {
       await lowCode.eventCenterController.fire(code);
      });
    };
    return {
      element,
      executeEvent,
    };
  },
});
</script>

<style  scoped>
</style>
